<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <base href="${request.contextPath}/"/>
    <meta charset="UTF-8">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,minimum-scale=1.0">
    <title>我的帖子</title>
    <link href="Content/wechat/css/reset.css" rel="stylesheet" type="text/css">
    <script src="Content/wechat/js/jquery.min.js"></script>
    <link href="Content/wechat/css/woDeTieZi.css" rel="stylesheet" type="text/css">
    <link href="Content/wechat/css/linLiSheQu.css" rel="stylesheet" type="text/css">
    <!--页码-->
    <link href="Content/wechat/css/myPagination.css" rel="stylesheet" type="text/css">
    <!--字体缩放-->
    <script src="Content/wechat/js/ziti.js"></script>
    <!--end 字体缩放-->
    <!--页码js-->
    <script src="Content/wechat/js/myPagination.js"></script>
</head>
<body>
<!--<header class="clearfix">-->
<!--&lt;!&ndash;    <a></a>&ndash;&gt;-->
<!--&lt;!&ndash;    <h2>我的帖子</h2>&ndash;&gt;-->
<!--</header>-->
<div class="liuYan">
    <div class="liuYan_box" id="liuYan_box">
        <!--        <div class="liuYan_box_1">-->
        <!--            <div class="delent clearfix">-->
        <!--                <button>删除</button>-->
        <!--                <span>2019-12-02</span>-->
        <!--            </div>-->
        <!--            <div class="neiRong_c" onclick=window.location="/wechat/forum/tongCheng_xx">-->
        <!--                <h4>漠河是大兴安岭地区县级市</h4>-->
        <!--                <p>近期计划去漠河旅游，我打算带上我一家人（四大一小）去玩玩，问下去玩几天比较合适，请问去过的要怎么样玩比较省心省钱少走弯路</p>-->
        <!--            </div>-->
        <!--            <div class="fenLei_down">-->
        <!--                <span class="tcjy">同城交友</span>-->
        <!--            </div>-->
        <!--        </div>-->

    </div>
    <!--页码-->
    <div id="pagination" class="pagination"></div>

    <script>
        var pageTotal = 0;   //总页数
        var pageSize = 10;    //一页显示几个
        window.onload = function () {
            InitAjax(1);
        }

        function onLoadPaging() {
            new myPagination({
                id: 'pagination',
                curPage: 1, //初始页码
                pageTotal: pageTotal, //总页数
                pageAmount: pageSize,  //每页多少条
                pageSize: 2, //可选,分页个数

                getPage: function (page) {
                    //获取当前页数
                    InitAjax(page)
                }
            })
        }

        function InitAjax(pageNum) {
            $.ajax({
                url: "/wechat/forum/my_list",
                type: 'post',
                dataType: 'json',
                data: {
                    pagination: "{page:\"" + pageNum + "\",rows:\"" + pageSize + "\",sidx:\"\",sord:\"\"}",
                    type: ""
                }, success: function (result) {
                    ajaxCallBack(result);
                }

            })
        }

        function ajaxCallBack(data) {
            var insetViewData = ""; //视图数据
            $.each(data.data.rows, function (index, items) {
                insetViewData += "<div class=\"liuYan_box_1\">\n" +
                    "            <div class=\"delent clearfix\">\n" +
                    "                <button onclick='delforum(\"" + items.id + "\")'>删除</button>\n" +
                    "                <span>" + items.date + "</span>\n" +
                    "            </div>\n" +
                    "            <div class=\"neiRong_c\" onclick=window.location=\"/wechat/forum/fornum_info?id=" + items.id + "\">\n" +
                    "                <h4>" + items.title + "</h4>\n" +
                    "                <p>" + items.content + "</p>\n" +
                    "            </div>\n" +
                    "            <div class=\"fenLei_down\">\n" + typeCss(items.type) +
                    "            </div>\n" +
                    "        </div>";

            });
            $("#liuYan_box").html(insetViewData);
            if (pageTotal == 0) {
                pageTotal = data.data.total;
                onLoadPaging()
            }
        }

        function typeCss(type) {
            var typeHtml = "";
            if (type == "同城交友") {
                typeHtml = " <span class=\"tcjy\">同城交友</span>";
            }
            if (type == "大事小情") {
                typeHtml = "  <span class=\"dsxq\">大事小情</span>";
            }
            if (type == "新鲜随拍") {
                typeHtml = " <span class=\"xxsp\">新鲜随拍</span>";
            }
            if (type == "求职招聘") {
                typeHtml = "<span class=\"wpmm\">求职招聘</span>";
            }

            if (type == "物品买卖") {
                typeHtml = "<span class=\"wpmm\">物品买卖</span>";
            }
            if (type == "房屋租售") {
                typeHtml = "<span class=\"wpmm\">房屋租售</span>";
            }

            if (type == "居民求助") {
                typeHtml = " <span class=\"wpmm\">居民求助</span>";
            }
            return typeHtml;

        }


        function delforum(id) {
// alert(id);
            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/wechat/forum/delForum",//url
                data: {
                    id: id
                },
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                    alert("删除成功！");
                    InitAjax(1);
                }
                ,
                error: function () {
                    alert("异常！");
                }
            });

        }

    </script>
    <!--end 页码-->

</div>

</body>
</html>
